/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ChatNI;

import common.*;
import ChatNI.FabriqueMessage.TypeMessage;
import java.io.File;
import java.net.InetAddress;
/**
 *
 * Usine
 * Class en charge of building the different types of messages used for the ChatSystem
 * It has two small factories
 * @see FabriqueMessage
 * @see FabriqueFile
 * @author Duy Duc, Metangmo
 */
public class Usine {
    
   private FabriqueMessage fabrique ;
    private FabriqueFile fabrique2 ;

    /**
     * Constructor
     */
    public Usine() {
        this.fabrique = new FabriqueMessage();
        this.fabrique2 = new FabriqueFile();
    }
    
    /**
     * formerMessage:
     * function forms the different types of message which are un product of FabriqueMessage 
     * @param type
     *        Type of the built message ( HELLO, BYE, TEXT )
     * @param addr
     *        IP Address of the recipient
     * @param username
     *        Nickname of the LocalUser
     * @param boo
     *        True/False signifies a demand of connection/a demand of addition in a list of user for the HELLO message
     * @param texte
     *        Content of TEXT message
     * @return
     *        Built message
     */
    public Message formerMessage (TypeMessage type, InetAddress addr, String username, Boolean boo, String texte) {
        Message mess = this.fabrique.creerMessage(type, addr, username, boo, texte);
        return mess;
    }
    
    /**
     * formerFile:
     * function forms the different types of message which are un product of FabriqueFile
     * @param type
     *        Type of the built message ( TRANSFERTFILEACCEPT, TRANSFERTFILEREQUEST, FICHIER )
     * @param addr
     *        IP Address of the recipient
     * @param tailleFic
     *        Size of the file (in bytes )
     * @param fic
     *        Pointer to the file
     * @param acc
     *        True/False signifies the accept/the deny of the TRANSFERTFILEACCEPT message
     * @param nomFic
     *        Name of the file
     * @return
     *        Built message
     */
    public Message formerFile (FabriqueFile.TypeMessage type, InetAddress addr, int tailleFic, File fic, Boolean acc,String nomFic) {
        Message mess = this.fabrique2.creerFile(type, addr, tailleFic, fic, acc, nomFic);
        return mess;
    }
}
